using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class KupuvanjeImot : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/Proekt.mdb;"; //postavuvame "adresa" do bazata
        OleDbConnection conn = new OleDbConnection(conString);

        conn.Open();

        string select = "SELECT ID, IME FROM POLINJA WHERE IGRACID IS NULL";
        OleDbCommand select_polinja = new OleDbCommand(select, conn);
        OleDbDataReader reader = select_polinja.ExecuteReader();

        while (reader.Read())
        {
            ListBox1.Items.Add(reader["IME"].ToString());
            
        }
        conn.Close();
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/Proekt.mdb;"; //postavuvame "adresa" do bazata
        OleDbConnection conn = new OleDbConnection(conString);

        conn.Open();

        string update = "UPDATE POLINJA SET IGRACID = ? WHERE IME = ?";
        OleDbCommand update_polinja = new OleDbCommand(update, conn);
        update_polinja.Parameters.AddWithValue("?", DropDownList1.SelectedValue.ToString());
        update_polinja.Parameters.AddWithValue("?", ListBox1.SelectedItem.ToString());
        update_polinja.ExecuteNonQuery();

        conn.Close();
        Response.Redirect("Admin.aspx");

        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Admin.aspx");
    }
}
